<?php
namespace Plugin\Alarm\Schema;

use Plugin\Alarm\Model\RdAlarmDangerType;
use Hyperf\Swagger\Annotation\Property;
use Hyperf\Swagger\Annotation\Schema;

/**
 * 隐患类别
 */
#[Schema(title: 'RdAlarmDangerTypeSchema')]
class RdAlarmDangerTypeSchema implements \JsonSerializable
{
    #[Property(property: 'id', title: 'id', type: 'bigint')]
    public string $id;

    #[Property(property: 'name', title: '隐患名称', type: 'string')]
    public string $name;

    #[Property(property: 'icon', title: '隐患图标', type: 'string')]
    public string $icon;

    #[Property(property: 'description', title: '隐患描述', type: 'string')]
    public string $description;

    #[Property(property: 'created_at', title: '创建时间', type: 'timestamp')]
    public string $created_at;

    #[Property(property: 'updated_at', title: '更新时间', type: 'timestamp')]
    public string $updated_at;

    public function __construct(RdAlarmDangerType $model)
    {
       $this->id = $model->id;
       $this->name = $model->name;
       $this->icon = $model->icon;
       $this->description = $model->description;
       $this->created_at = $model->created_at;
       $this->updated_at = $model->updated_at;
    }

    public function jsonSerialize(): array
    {
        return [
            'id' => $this->id,
            'name' => $this->name,
            'icon' => $this->icon,
            'description' => $this->description,
            'created_at' => $this->created_at,
            'updated_at' => $this->updated_at
        ];
    }
}